package listbyorder.access001_100.test96;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/6/6 10:02
 */
public class Solution1 {

    // 计算二叉树有多少种
    public int numTrees(int n) {
        if (n < 2) return 1;
        int[] dp = new int[n + 1];
        dp[0] = dp[1] = 1;
        for (int i = 2; i < n + 1; i++) {
            int times = 0;
            for (int j = 1; j <= i; j++) {
                times += dp[j - 1] * dp[i - j];
            }
            dp[i] = times;
        }
        return dp[n];
    }
}
